import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;


public class a {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        // 读取链表长度
        int n = Integer.parseInt(br.readLine());

        // 读取链表节点值
        String[] values = br.readLine().split(" ");

        // 创建虚拟头节点
        ListNode dummy = new ListNode(0);
        ListNode current = dummy;

        int prevVal = Integer.MIN_VALUE;

        for (int i = 0; i < n; i++) {
            int val = Integer.parseInt(values[i]);

            // 只有当当前值与前一个值不同时，才添加到链表中
            if (val != prevVal) {
                current.next = new ListNode(val);
                current = current.next;
            }
            prevVal = val;
        }

        // 输出结果链表
        ListNode result = dummy.next;
        if (result == null) {
            out.println("NULL");
        } else {
            StringBuilder sb = new StringBuilder();
            while (result != null) {
                sb.append(result.val);
                if (result.next != null) {
                    sb.append(" -> ");
                }
                result = result.next;
            }
            out.println(sb.toString());
        }

        out.flush();
        br.close();
    }
}

